Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SetharikaSok_Adagrams_Atlanta #107

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

SetharikaSok
Copy link

No description provided.

Comment on lines +32 to +37
drawn_letter = []
all_list = letters.items()
mynew_list = list(all_list)

while len(drawn_letter) < 10:
random_number = random.randrange(0,len(mynew_list))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small comment here, so in the project description it says that certain letters should have a higher probability of being chosen than other letters. For example, E should have the highest probability to be chosen since the LETTER_POOL says that there are 12 of them (line 8). What you have on lines 33-34 don't necessarily take those weights into account. All letters have an equal chance of being chosen. A solution that considers those weights could look like this:

def draw_letters():
   drawn_letters = []
   letters = []
   for letter in LETTER_POOL.keys():
       letters += letter * LETTER_POOL[letter]

   while True:
    if len(drawn_letters) == 10: break

    index = random.randint(0,len(letters) - 1)
    chosen_letter = letters[index]

    if drawn_letters.count(chosen_letter) < LETTER_POOL[chosen_letter]:
        drawn_letters.append(chosen_letter)

   return drawn_letters

In the beginning of the function we loop through the keys in LETTER_POOL to create a list with their appropriate weights. letters += 'S' * 4 --> letters = ['S', 'S', 'S', 'S']

Comment on lines +52 to +53
for i in letter_bank:
for j in word.upper():

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job Rika on implementing a nested loop! This shows me that you are showing proficiency in them! An alternative way you could have implemented this is:

def uses_available_letters(word, letter_bank):
    cap_word = word.upper()

    for letter in cap_word:
       if letter not in letter_bank: return False

       if cap_word.count(letter) > letter_bank.count(letter): return False
    
    return True

Python has a method for iterables called count and what it does is count the instances of the value passed to it inside of the iterable it is being called on. That way we don't have to create another loop to compare each letter in word to each element in letter_bank.

if len(word) in range(7, 11):
count_point += 8

return count_point

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work on this function! Very concise and easy to follow! ⭐️

winner_dict = {}

for word in word_list:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One suggestion I have for you is maybe handling the determination of winner_score in this loop here, that way you don't have to worry about it when implementing the tiebreaker logic. We could do something like this here:

 highest_score = 0
    winning_words = []

    for word in word_list:
       score = score_word(word)
       
       if score > highest_score:
          highest_score = score
          winning_words = [word]
       elif score == highest_score:
          winning_words.append(word)

With this implementation we filter out words whose score is lower than the winning_score. That way when we get to the tie breaking logic we only have to worry about the length of words and not the score. This is because all the words found inside of winning_words all have a score equal to highest_score. But again, nothing is wrong with how you implemented your solution, this is just an alternative approach. Nonetheless, good job!




Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, Rika! You are really showing some proficiency! Please feel free to contact me if you need any clarification about the comments I left! I can't wait to see more of your code in the future! 🤩

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants